// hero-stories.js
const app=getApp();
Page({
  data: {
    HeroList: [],
  },

  onLoad() {
    this.getHeroList(),
    wx.setNavigationBarTitle({
      title: '榜样力量'
    });
  },
  getHeroList(){
    wx.request({
  url: `${app.globalData.baseUrl}/api/excellentPersonnel/list`,
  method:'GET',
  success:(res)=>{
if(res.statusCode===200){
     this.setData({
      HeroList : res.data.data
     });
     console.log(res.data.data)
   }else{
     console.error('请求失败，状态码:', res.statusCode);
   }
},
fail:(err) =>{
       console.log('请求失败:', err);
}
})
},

goToDetail(e) {
  const id = e.currentTarget.dataset.id; // 确保这里能正确获取到 ID
  console.log('传递的英雄 ID:', id); // 添加这行日志，检查是否获取到 ID
  wx.navigateTo({
    url: `/pages/person/Previous-excellent/Previous-detail/Previous-detail?id=${id}`,
  });
}
});